package com.lysj.bhp.blacklist.repository;

import com.lysj.bhp.blacklist.domain.Blacklist;
import com.lysj.bhp.blacklist.vo.BlacklistVo;
import jnr.ffi.annotations.In;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.Date;
import java.util.List;

/**
 * @Author: ZhangWenJian
 * @Create: 2018/8/14--8:51
 * @Description:黑名单Jpa
 */
public interface BlacklistRepository extends JpaRepository<Blacklist,Long> , JpaSpecificationExecutor {
    //查找黑名单连表用户 Friend 1.userAccount 2.status 1
    @Query("SELECT new  com.lysj.bhp.blacklist.vo.BlacklistVo (a.blacklistId,a.userId,a.createDate,a.createReason,a.overdueAmount,a.releaseDate,a.overdueLevel,b.email) from Blacklist a,User b where a.userId = b.userId and a.isExist = 1 and a.overdueLevel >0 order by a.createDate desc ")
    List<BlacklistVo> findBlacklistVoList();
    //查找黑名单状态为正常的黑名单数据
    Blacklist findByBlacklistIdAndIsExist(Long blacklistId, Integer isExist);
    //查找已经可以出小黑屋的用户
    List<Blacklist> findByReleaseDateAndIsExist(Date punishmentCycle, Integer isExist);
    //查找某用户是否存在
    Blacklist findByUserIdAndIsExist(Long userId,Integer isExist);


}
